{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Network Pruning\n",
    "\n",
    "In eve-mli, you can perform a pruning operation on network in a lightly way under the help of eve parameter."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import necessary packages.\n",
    "# at the beginning, ensure that the eve-mli package is in your python path.\n",
    "# or you just install it via `pip install eve-mli`.\n",
    "\n",
    "import os\n",
    "import time\n",
    "from datetime import datetime\n",
    "\n",
    "import random\n",
    "import numpy as np\n",
    "import torch as th\n",
    "import torch.nn as nn\n",
    "import torch.nn.functional as F\n",
    "\n",
    "import eve\n",
    "import eve.app\n",
    "import eve.app.model\n",
    "import eve.app.trainer\n",
    "import eve.core\n",
    "import eve.core.layer\n",
    "\n",
    "from matplotlib import pyplot as plt\n",
    "%matplotlib inline\n",
    "\n",
    "os.environ[\"CUDA_VISIBLE_DEVICES\"] = '1'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# build a basic network for trainer\n",
    "class mnist(eve.core.Eve):\n",
    "    def __init__(self):\n",
    "        super().__init__()\n",
    "        \n",
    "        self.conv1 = nn.Sequential(\n",
    "            nn.Conv2d(1, 4, 3, stride=2, padding=1),\n",
    "            nn.BatchNorm2d(4),\n",
    "        )\n",
    "        self.pruner1 = eve.core.Pruner(eve.core.State(self.conv1))\n",
    "\n",
    "        self.conv2 = nn.Sequential(\n",
    "            nn.Conv2d(4, 8, 3, stride=2, padding=1),\n",
    "            nn.BatchNorm2d(8),\n",
    "        )\n",
    "        self.pruner2 = eve.core.Pruner(eve.core.State(self.conv2))\n",
    "\n",
    "        self.conv3 = nn.Sequential(\n",
    "            nn.Conv2d(8, 16, 3, stride=2, padding=1),\n",
    "            nn.BatchNorm2d(16),\n",
    "        )\n",
    "        self.pruner3 = eve.core.Pruner(eve.core.State(self.conv3))\n",
    "\n",
    "        self.linear1 = nn.Linear(16 * 4 * 4, 16)\n",
    "        self.pruner4 = eve.core.Pruner(eve.core.State(self.linear1))\n",
    "\n",
    "        self.linear2 = nn.Linear(16, 10)\n",
    "\n",
    "    def forward(self, x):\n",
    "        conv1 = self.conv1(x)\n",
    "        pruner1 = self.pruner1(conv1)\n",
    "\n",
    "        conv2 = self.conv2(pruner1)\n",
    "        pruner2 = self.pruner2(conv2)\n",
    "\n",
    "        conv3 = self.conv3(pruner2)\n",
    "        pruner3 = self.pruner3(conv3)\n",
    "\n",
    "        pruner3 = th.flatten(pruner3, start_dim=1).unsqueeze(dim=1)\n",
    "\n",
    "        linear1 = self.linear1(pruner3)\n",
    "        pruner4 = self.pruner4(linear1)\n",
    "\n",
    "        linear2 = self.linear2(pruner4)\n",
    "\n",
    "        return linear2.squeeze(dim=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# define a MnistClassifier\n",
    "# Classifier uses the corss entropy as default.\n",
    "# in most case, we just rewrite the `prepare_data`.\n",
    "class MnistClassifier(eve.app.model.Classifier):\n",
    "    def prepare_data(self, data_root: str):\n",
    "        from torch.utils.data import DataLoader, random_split\n",
    "        from torchvision import transforms\n",
    "        from torchvision.datasets import MNIST\n",
    "\n",
    "        train_dataset = MNIST(root=data_root,\n",
    "                              train=True,\n",
    "                              download=True,\n",
    "                              transform=transforms.ToTensor())\n",
    "        test_dataset = MNIST(root=data_root,\n",
    "                             train=False,\n",
    "                             download=True,\n",
    "                             transform=transforms.ToTensor())\n",
    "        self.train_dataset, self.valid_dataset = random_split(\n",
    "            train_dataset, [55000, 5000])\n",
    "        self.test_dataset = test_dataset\n",
    "\n",
    "        self.train_dataloader = DataLoader(self.train_dataset,\n",
    "                                           batch_size=128,\n",
    "                                           shuffle=True,\n",
    "                                           num_workers=4)\n",
    "        self.test_dataloader = DataLoader(self.test_dataset,\n",
    "                                          batch_size=128,\n",
    "                                          shuffle=False,\n",
    "                                          num_workers=4)\n",
    "        self.valid_dataloader = DataLoader(self.valid_dataset,\n",
    "                                           batch_size=128,\n",
    "                                           shuffle=False,\n",
    "                                           num_workers=4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# store accuracy result\n",
    "y = {}\n",
    "def plot():\n",
    "    global y\n",
    "    keys, values = list(y.keys()), list(y.values())\n",
    "    for k, v in y.items():\n",
    "        plt.plot(v, \n",
    "                 color='green' if random.random() > 0.5 else \"red\", \n",
    "                 marker='o' if random.random() > 0.5 else \"*\", \n",
    "                 linestyle='-' if random.random() > 0.5 else \":\", \n",
    "                 label=k)\n",
    "    plt.title('accuracy over epoches (train)')\n",
    "    plt.xlabel('epochs')\n",
    "    plt.ylabel('accuracy')\n",
    "    plt.legend(loc=\"upper left\")\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def train(trainer, exp_name: str = \"snn\"):\n",
    "    global y\n",
    "    # train 10 epoches and report the final accuracy\n",
    "    y[exp_name] = []\n",
    "    tic = datetime.now()\n",
    "    for _ in range(10):\n",
    "        info = trainer.fit()\n",
    "        y[exp_name].append(info[\"acc\"])\n",
    "    info = trainer.test()\n",
    "    toc = datetime.now()\n",
    "    y[exp_name] = np.array(y[exp_name])\n",
    "    print(f\"Test Accuracy: {info['acc']*100:.2f}%, Elapsed time: {toc-tic}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## l1 norm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "===> Train\n",
      "Test Accuracy: 92.38%, Elapsed time: 0:00:51.982259\n",
      "===> Pruning\n",
      "Test Accuracy: 92.35%, Elapsed time: 0:00:52.857012\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEWCAYAAAB8LwAVAAAAOXRFW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CdUdZr7mqCqd0RZrqf3rdkfNhwA0lS1DeeBVs8DXwHe6OF7G9NjliCM6d5fgUtEZDCAiBSKyGic/59L3GUuB/6hqnuAWhE51Z3+DeBd9wl9fhG5yH2PTBHJ6WyD7jM5Bro3SvwhziM+jTmikvpursbEQlU/FpGfA2+JSArQCnwX56E55e68nTjtFADfAh50E0D4XU+/ATwkIne67/G1LjabD7wkIlk4ZzA/6uWPZUy37G6uxvSQiNSrap7XcRgTL1bFZIwxJio7gzDGGBOVnUEYY4yJyhKEMcaYqCxBGGOMicoShDHGmKgsQRhjjInq/wPT286SbToYVAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# reset result\n",
    "y = {}\n",
    "\n",
    "# Don't forget to reset global statistic, otherwise may cause cuda error\n",
    "eve.core.State.reset_global_statistic()\n",
    "\n",
    "# register the global pruning function\n",
    "eve.core.State.register_global_statistic(\"l1_norm\")\n",
    "\n",
    "# define net\n",
    "pruning_neural_network_l1_norm = mnist()\n",
    "\n",
    "# replace the data_root for your path.\n",
    "classifier = MnistClassifier(pruning_neural_network_l1_norm)\n",
    "classifier.prepare_data(data_root= \"/home/densechen/dataset\")\n",
    "\n",
    "# use default configuration\n",
    "classifier.setup_train()\n",
    "\n",
    "# assign model to trainer\n",
    "eve.app.trainer.BaseTrainer.assign_model(classifier)\n",
    "\n",
    "trainer = eve.app.trainer.BaseTrainer()\n",
    "\n",
    "# Train it\n",
    "print(\"===> Train\")\n",
    "train(trainer, \"train\")\n",
    "\n",
    "print(\"===> Pruning\")\n",
    "# use upgrader to do pruning automatically\n",
    "upgrader = eve.app.upgrader.Upgrader(pruning_neural_network_l1_norm.eve_parameters())\n",
    "upgrader.step()\n",
    "\n",
    "train(trainer, \"pruning\")\n",
    "\n",
    "plot()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## fire rate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "===> Train\n",
      "Test Accuracy: 92.15%, Elapsed time: 0:00:53.528946\n",
      "===> Pruning\n",
      "Test Accuracy: 92.40%, Elapsed time: 0:00:53.454817\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEWCAYAAAB8LwAVAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAA4Z0lEQVR4nO3de3hU5bn///cnARLC+RBECQRURIKKVgSsx122LWqtta1Fi61aK+5W3erWr4fS39bLvfna3fqtp1qVVmsVPNW2Sj1WrdpdGRCUk4AocpyAGiBEzuRw//5YazKTZEKGkMkkmft1XXPNPOt4z5rkuddaz3rWkpnhnHPO1ZeT6QCcc861TZ4gnHPOJeUJwjnnXFKeIJxzziXlCcI551xSniCcc84l5QnCuQ5I0iWS/tlK63pH0nEtuLxTJK1IcdpjJM1uqXW7ujxBOOeaTdI5wDYzWxCWb5M040CWaWb/a2YjUpx2MbA1jMO1ME8QLqMU6DB/h5I6ZTqGVvZvwOOpTpym33smcEULL9PhCcIBkm6W9ImkbZKWSTqv3vjLJS1PGP+lcPhgSX+WVCZps6Rfh8Pr7EVKGirJYpWnpLckTZP0DrATOFTSpQnrWCXpinoxnCtpoaQvwlgnSjpf0nv1pvsPSc838j0PkTRL0hZJKyVdnjB8l6S+CdMeJ2mTpM5h+YdhfOWSXpVUnDCtSbpS0sfAx42se7yk2ZK2Slok6fSEcW9JukPSu+H3e75eLN+QtDSc9y1JIxPGJf0NEsbfGca8WtKZCcN7SXpY0kZJpZL+W1JuOO5wSW9Lqgi3wdONfKcuwFeAt8PyROCnwCRJ2yUtSvh+Kf/ekk6XFE0or5F0g6T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gkd8Oteqsvpurs6lwsyWSfoZ8DdJOUAlcCXBQ3PGhuM+J2inALgYeDBMAIl3Pf0+8JCk28NlnL+P1fYAnpeUT3AE8x8t/LWca5LfzdW5ZpK03cy6ZzoO59LFTzE555xLyo8gnHPOJeVHEM4555LyBOGccy4pTxDOOeeS8gThnHMuKU8Qzjnnkvr/AUjCMYrgcdWvAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# reset result\n",
    "y = {}\n",
    "\n",
    "# Don't forget to reset global statistic, otherwise may cause cuda error\n",
    "eve.core.State.reset_global_statistic()\n",
    "\n",
    "# register the global pruning function\n",
    "eve.core.State.register_global_statistic(\"fire_rate\")\n",
    "\n",
    "# define net\n",
    "pruning_neural_network_fire_rate = mnist()\n",
    "\n",
    "# replace the data_root for your path.\n",
    "classifier = MnistClassifier(pruning_neural_network_fire_rate)\n",
    "classifier.prepare_data(data_root=\"/home/densechen/dataset\")\n",
    "\n",
    "# use default configuration\n",
    "classifier.setup_train()\n",
    "\n",
    "# assign model to trainer\n",
    "eve.app.trainer.BaseTrainer.assign_model(classifier)\n",
    "\n",
    "trainer = eve.app.trainer.BaseTrainer()\n",
    "\n",
    "# Train it\n",
    "print(\"===> Train\")\n",
    "train(trainer, \"train\")\n",
    "\n",
    "print(\"===> Pruning\")\n",
    "# use upgrader to do pruning automatically\n",
    "upgrader = eve.app.upgrader.Upgrader(pruning_neural_network_fire_rate.eve_parameters())\n",
    "upgrader.step()\n",
    "\n",
    "train(trainer, \"pruning\")\n",
    "\n",
    "plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
